import com.yanjingzheng.entity.AbstractLogger;
import com.yanjingzheng.entity.ConsoleLogger;
import com.yanjingzheng.entity.ErrorLogger;
import com.yanjingzheng.entity.FileLogger;

/**
 * @Author Yenchingcheng
 * @Date 2023/9/12 13:54
 * @Description 测试类
 **/
public class Main {

    public static AbstractLogger getChainOfLoggers(){

        AbstractLogger errorLogger = new ErrorLogger(AbstractLogger.ERROR);
        AbstractLogger fileLogger = new FileLogger(AbstractLogger.DEBUG);
        AbstractLogger consoleLogger = new ConsoleLogger(AbstractLogger.INFO);

        errorLogger.setNextLogger(fileLogger);
        fileLogger.setNextLogger(consoleLogger);

        return errorLogger;
    }

    public static void main(String[] args) {
        AbstractLogger chainLogger = getChainOfLoggers();

        chainLogger.logMessage(AbstractLogger.INFO,"This is a nomal Infomation.");
        System.out.println();
        chainLogger.logMessage(AbstractLogger.DEBUG,"This is a debug level Infomation.");
        System.out.println();
        chainLogger.logMessage(AbstractLogger.ERROR,"This is an error level Infomation.");
    }
}
